<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
/* <![CDATA[ */
table, td
{
    border-color: #666;
    border-style: solid;
}
table, th
{
    border-color: #666;
    border-style: solid;
}

table
{
    border-width: 0 0 1px 1px;
    border-spacing: 0;
    border-collapse: collapse;
}
 
td
{
    margin: 0;
    padding: 4px;
    border-width: 1px 1px 0 0;
}
th
{
    margin: 0;
    padding: 4px;
    border-width: 1px 1px 0 0;
}
/* ]]> */


</style>
<link rel="stylesheet" href="/js/chosen/chosen2.css" />

</head>
<body style="font-family:Arial, Helvetica, sans-serif">


<?php $oList = $this->oList; 
$category2 = "";
$prCate = new Model_DbTable_Pr_Category();?>
<?php
if(empty($this->oList)){	
?>
<div style="border:#900 solid 2px; padding:15px; font-weight:bold;" > Stop! The order hasn't been generate, please go back to last page and tick the "re-generate order" check box</div>
<?php
}
else{
?>

<form id="form1" name="form1" method="post" action="">
<h1>Repair Parts Order</h1>
<h1>No.: <?php echo $oList[0]["part_order_number"]; ?><input type="hidden" name="part_order_number" value="<?php echo $oList[0]["part_order_number"]; ?>" /><br />
<?php 
	
	$rOrder = new Model_DbTable_Pr_Order();
	$isConfirmed = $rOrder->isOrderConfirmed($oList[0]["part_order_number"]);
	
	if($isConfirmed){
		?>
	<span style="color:#090"> Order has Sent to Warehouse Already</span>
	<?php 	
	}
	else{
		?>
	<span style="color:#900" > Order Still not Send to Warehouse Yet</span>
	<?php 	
	}
?>

</h1>
<ul>
  <li>  You Order Will be available FROM Every Monday</li>
  <li>Current Over Only Include Last Week Sales, Not Sold Out Item Include, Add by yourself.<br />
   </li>
</ul>   
    <p>ADD Extra Product:
      <select name="add_part_code" id="add_part_code" class="chzn-select" >
        <option value=""></option>
        <?php foreach($this->pList as $rPart ) {?>
        <option value="<?php echo $rPart['id_product']?>">[<?php echo $rPart['code_product']?>]   -  <?php echo $rPart['title_product']?></option>
        <?php } ?>
      </select>
    <input type="submit" name="btn_add" id="btn_add" value="ADD INTO ORDER" />
    
    </p>
    <p>** Please Add Product One By One With Zero Qty, Modify the Qty AFTER finish Adding ALL OF the Products<br />
      ** After Modify The Qty, You need to Click &quot;Save For Modify Later&quot;, Qty Changes will be SAVED, Otherwise <br />
      Qty of your added Product will remain 0<br /></p>
      <h2>BackOrder is Available Now!!<br />
      You Do Not Need To Order Extra If you already Have Back Order Pending For This Parts</h2>
      
    
  <table width="1200" cellspacing="1" cellpadding="0">
      
    <tr>
    <th rowspan="2" scope="col">ID</th>
    <th rowspan="2" scope="col">Part</th>
    <th rowspan="2" scope="col"  style="width:300px;">Description</th>
    <th colspan="2" scope="col">Sales</th>
    <th rowspan="2" scope="col">Faulty</th>
    <th colspan="3" scope="col">Stock</th>
    <th colspan="2" scope="col">
      Order<br /></th>
    <th rowspan="2" scope="col" style="width:150px;">Reason<br />
      <span style="font-size:8px">(For Over Stock)</span></th>
    </tr>
  <tr>
    <th scope="col"><span style="font-size:12px">Last Wk Ave</span></th>
    <th scope="col"><span style="font-size:12px">Max 4 Wks</span></th>
    <th scope="col"><span style="font-size:12px">System<br />
      On Hand</span></th>
    <th scope="col" style=" background-color:#CCC;" ><span style="font-size:12px;">Actual<br />
      On Hand</span></th>
    <th scope="col"><span style="font-size:12px">Wh</span></th>
    <th scope="col"><span style="font-size:10px">Recom<br />
    Order Qty</span></th>
    <th scope="col"  style=" background-color:#CCC;"  ><span style="font-size:10px"  >Your<br />
    Order Qty</span></th>
    </tr>
  <?php 
	$rProduct = new Model_DbTable_Pr_Prproducts();

 foreach($this->oList as $orderRow) {
	 if($orderRow["code_product"]!="SERVICE"){
	 	$prDetail = $rProduct->getProduct($orderRow["id_product"]);
	 	$category1 = $prDetail['id_cate'];
	 	if($category1 != $category2){
	 		$category2 = $category1;
	 		$cateTitle = $prCate->getCategory($category2); ?>
	 	<tr>
	 		<td colspan = "19" style=" background-color:#80FF80" align = "center"><strong style="line-height:25px; display:inline-block; font-size:18px;"><?php echo $cateTitle['title_cate'];?></strong></td>
	 	</tr>	
	 		
	 		
	<?php  	}
	 ?> 
  <tr>
    <td><?php echo $orderRow["id_product"]?></td>
    <td><?php echo $orderRow["code_product"]?></td>
    <td><span style="font-size:12px;"><?php echo $prDetail['title_product']?></span></td>
    <td align="center"><?php echo $orderRow["qty_last_week"]?></td>
    <td align="center"><?php echo $orderRow["qty_max_week"]?></td>
    <td align="center"><?php echo $orderRow["qty_fo_last_week"]?></td>
    <td align="center"><?php echo $orderRow["qty_onhand"]?></td>
    <td align="center"  style=" background-color:#CCC;"  ><?php echo $orderRow["qty_onhand_cf"]?></td>
    <td align="center"><?php echo $orderRow["qty_wh"]?></td>
    <td align="center"><?php echo $orderRow["qty_order"]?><input type="hidden" name="recom_qty[<?php echo $orderRow["id_order"]?>]" id="recom_qty_<?php echo $orderRow["id_order"]?>" value="<?php echo $orderRow["qty_order"]?>"  /></td>
    <td align="center"  style=" background-color:#CCC;"  ><input type="text" name="qty_order[<?php echo $orderRow["id_order"]?>]" id="qty_order<?php echo $orderRow["id_order"]?>2" style="width:50px;" value="<?php if(!empty($orderRow['qty_order_actual'])){echo $orderRow['qty_order_actual'];}else{echo $orderRow["qty_order"];} ?>"  /></td>
    <td align="left"><input name="reason[<?php echo $orderRow["id_order"]?>]" type="text" value="<?php echo $orderRow["reason"]?>" style="width:150px;" /></td>
    </tr>
  <?php } } ?> 
  <?php
$arrExtOrder = unserialize(base64_decode($this->arrExtOrder));
foreach($arrExtOrder as $extLine){
?> 
  <tr>
    <td><?php echo $extLine[0]?></td>
    <td><?php echo $extLine[1]?></td>
    <td><span style="font-size:12px;"><?php echo $extLine[2];?></span></td>
    <td align="center"><?php echo $extLine[3]?></td>
    <td align="center"><?php echo $extLine[4]?></td>
    <td align="center"><?php echo $extLine[5]?></td>
    <td align="center"><?php echo $extLine[6]?></td>
    <td align="center"  style=" background-color:#CCC;"  ><label for="qty_onhand_cf_ext"></label>
      <input type="text" name="qty_onhand_cf_ext[<?php echo $extLine[0]?>]" id="qty_onhand_cf_ext<?php echo $extLine[0]?>" style="width:50px;background-color:#FFA4A4;" value="<?php echo $extLine[9];?>"  /></td>
    <td align="center"><?php echo $extLine[7]?></td>
    <td align="center"><?php echo $extLine[8]?></td>
    <td align="center"  style=" background-color:#CCC;"  ><input type="text" name="qty_ext_order[<?php echo $extLine[0]?>]" id="qty_ext_order<?php echo $extLine[0]?>2" style="width:50px;" value="<?php echo $extLine[8]?>" /></td>
    <td align="left" valign="middle"><input name="id_remove[<?php echo $extLine[0]?>]" type="checkbox" value="1" />
      <img src="/im/no20.jpg" title="Tick For Remove" /> <span style="font-size:12px;">tick  to remove</span></td>
    </tr>
  <?php }?> 
  <tr>
    <td colspan="3" align="right" style="padding:20px;" ><label for="staff_name"></label>
    Your Attendance Password:
        <input type="password" name="staff_name" id="staff_name" />
     
        <br />
       Only Input When Submit the Finial Order      
        <br />
      
      
  <br />
  <input name="btn_save" type="submit" id="btn_save" value="Save For Modify Later" />&nbsp;&nbsp;&nbsp;<input name="btn_confirm" type="submit" value="Confirm &amp; Send to Warehouse" id="btn_confirm" />
      <br />
  <br /> 
  <span style="font-size:12px;">*Buttons WIll only be Enable after you Modify the Staff Name<br />
  * Once you save or confirm it,<u>Extra Product can not be removed</u></span>
      </td>
    <td colspan="10" align="right" style="padding:20px;" ><input type="hidden" name="arr_ext_order" id="arr_ext_order" value="<?php echo $this->arrExtOrder;?>" />   <input type="submit" name="btn_del" id="btn_del" value="Remove Selected" /></td>
    </tr>
  
</table>
 </form>
 <?php }?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script src="/js/chosen/chosen.jquery.js" type="text/javascript"></script>
<script type="text/javascript"> 
    var config = {
      '.chzn-select': {allow_single_deselect:true},
    }
    for (var selector in config) {
      $(selector).chosen(config[selector]);
    };
$(document).ready(function() {

$('#staff_name').keyup(function(){
	var sname = $(this).val();
	var length = sname.length;
	if(length >1){
		$('#btn_confirm').removeAttr('disabled');
		}
	});
});	
  </script>

</body>
</html>
